﻿@inherits TestComponentBase

<Fixture Tests="new Action[]{ TheComponentRendersExpectedOutput, WhenItemIsClickedOnCompleteEventIsRaised }">
    <ComponentUnderTest>
        <TodoItem Todo="todo" OnCompleted="id => clickedTodoId = id"></TodoItem>
    </ComponentUnderTest>
    <Fragment>
        <li id="todo-@todo.Id" class="list-group-item list-group-item-action">
            <span>@todo.Text</span>
            <span class="float-right text-danger">(click to complete)</span>
        </li>
    </Fragment>
</Fixture>
@code {
    Todo todo = new Todo { Id = 42, Text = "Hello world" };
    int clickedTodoId = 0;

    void TheComponentRendersExpectedOutput()
    {
        // act
        var cut = GetComponentUnderTest();
        var expected = GetFragment();

        // assert
        cut.MarkupMatches(expected);
    }

    void WhenItemIsClickedOnCompleteEventIsRaised()
    {
        var cut = GetComponentUnderTest();

        cut.Find("li").Click();

        Assert.Equal(todo.Id, clickedTodoId);
    }
}